<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  props: {
    type: String,
  },
  emits: {
    getPhoneNumber: (e: any) => true,
  },
  setup(props, ctx) {
    const getPhoneNumber = (e: MiniApp.Event<any>) => {
      const data = e.detail;
      console.log("getPhoneNumber", data);
      if (!data.errMsg.includes("ok")) return;
      ctx.emit("getPhoneNumber", data);
    };

    return { getPhoneNumber };
  },
});
</script>

<template>
  <button class="open-btn" :open-type="type" @getphonenumber="getPhoneNumber" />
</template>

<style lang="scss">
.open-btn {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
}
</style>